package com.st.config;

import com.st.interceptor.MyInterceptor;
import com.st.interceptor.QianTaiInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

//配置类 启动前被加载
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    //依赖注入
    @Resource
    private MyInterceptor myInterceptor;
    @Resource
    private QianTaiInterceptor qianTaiInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截类对象
        registry.addInterceptor(myInterceptor)
                .addPathPatterns("/admin/*","/goods/*","/index/*","/order/*","/product/*").excludePathPatterns("/static/**");
        registry.addInterceptor(qianTaiInterceptor).addPathPatterns("/cart/*","/myOrder/*","/sg/*","/so/*","/user/*")
                .excludePathPatterns("/static/**","/user/main","/cs/cs");
    }
}
